dist: trusty
language: cpp
sudo: true
notifications:
    email:
        recipients:
            - nemo@nil.foundation
        on_success: change
        on_failure: always

env:
    global: _GLOBAL_BUILD="-DBUILD_TESTS=TRUE"

matrix:
    include:
        -   os: linux
            addons:
                apt:
                    sources:
                        - ubuntu-toolchain-r-test
                    packages:
                        - g++-4.7
            env: _CC=gcc-4.7 _CXX=g++-4.7
        -   os: linux
            addons:
                apt:
                    sources:
                        - ubuntu-toolchain-r-test
                    packages:
                        - g++-4.8
            env: _CC=gcc-4.8 _CXX=g++-4.8
        -   os: linux
            addons:
                apt:
                    sources:
                        - ubuntu-toolchain-r-test
                    packages:
                        - g++-4.9
            env: _CC=gcc-4.9 _CXX=g++-4.9
        -   os: linux
            addons:
                apt:
                    sources:
                        - ubuntu-toolchain-r-test
                    packages:
                        - g++-5
            env: _CC=gcc-5 _CXX=g++-5
        -   os: linux
            addons:
                apt:
                    sources:
                        - ubuntu-toolchain-r-test
                    packages:
                        - g++-5
            env: _CC=gcc-5 _CXX=g++-5 _BUILD="-DCMAKE_CXX_STANDARD=14"
        -   os: linux
            addons:
                apt:
                    sources:
                        - ubuntu-toolchain-r-test
                    packages:
                        - g++-6
            env: _CC=gcc-6 _CXX=g++-6
        -   os: linux
            addons:
                apt:
                    sources:
                        - ubuntu-toolchain-r-test
                    packages:
                        - g++-6
            env: _CC=gcc-6 _CXX=g++-6 _BUILD="-DCMAKE_CXX_STANDARD=14"
        -   os: linux
            addons:
                apt:
                    sources:
                        - ubuntu-toolchain-r-test
                    packages:
                        - g++-7
            env: _CC=gcc-7 _CXX=g++-7
        -   os: linux
            addons:
                apt:
                    sources:
                        - ubuntu-toolchain-r-test
                    packages:
                        - g++-7
            env: _CC=gcc-7 _CXX=g++-7 _BUILD="-DCMAKE_CXX_STANDARD=14"
        -   os: linux
            addons:
                apt:
                    sources:
                        - ubuntu-toolchain-r-test
                        - llvm-toolchain-precise-3.8
                    packages:
                        - clang-3.8
                        - g++-5
            env: _CC=clang-3.8 _CXX=clang++-3.8 _BUILD="-DCMAKE_CXX_STANDARD=14"
        -   os: linux
            addons:
                apt:
                    sources:
                        - llvm-toolchain-trusty-3.9
                        - ubuntu-toolchain-r-test
                    packages:
                        - clang-3.9
                        - g++-5
            env: _CC=clang-3.9 _CXX=clang++-3.9 _BUILD="-DCMAKE_CXX_STANDARD=14"
        -   os: linux
            addons:
                apt:
                    sources:
                        - llvm-toolchain-trusty-4.0
                        - ubuntu-toolchain-r-test
                    packages:
                        - clang-4.0
                        - g++-5
            env: _CC=clang-4.0 _CXX=clang++-4.0 _BUILD="-DCMAKE_CXX_STANDARD=14"
        -   os: linux
            addons:
                apt:
                    sources:
                        - llvm-toolchain-trusty-5.0
                        - ubuntu-toolchain-r-test
                    packages:
                        - clang-5.0
                        - g++-5
            env: _CC=clang-5.0 _CXX=clang++-5.0 _BUILD="-DCMAKE_CXX_STANDARD=14"

before_install:
    - sudo add-apt-repository -y ppa:george-edison55/cmake-3.x
    - sudo add-apt-repository -y ppa:mhier/libboost-latest
    - sudo apt-get update -q
    - sudo apt-get install libboost1.67-dev libc++-dev cmake cmake-data -y
    - if [[ ${_CC} == clang* ]]; then sudo apt-get remove gcc-4.8 g++-4.8 -y; fi

script:
    - echo "------------------ Debug build ------------------"
    - mkdir build.debug
    - cd build.debug
    - CC=${_CC} CXX=${_CXX} cmake .. ${_BUILD} ${_GLOBAL_BUILD}
    - if [[ $TRAVIS_OS_NAME == linux ]]; then
        VERBOSE=1 sudo make -j$(nproc) tests;
        elif [[ $TRAVIS_OS_NAME == osx ]]; then
        VERBOSE=1 sudo make -j$(sysctl -n hw.ncpu) tests;
        fi
    - ctest
    - cd ..
    - echo "------------------ Release build ------------------"
    - mkdir build.release
    - cd build.release
    - CC=${_CC} CXX=${_CXX} cmake .. ${_BUILD} ${_GLOBAL_BUILD} -DCMAKE_BUILD_TYPE=Release
    - if [[ $TRAVIS_OS_NAME == linux ]]; then
        VERBOSE=1 sudo make -j$(nproc) tests;
        elif [[ $TRAVIS_OS_NAME == osx ]]; then
        VERBOSE=1 sudo make -j$(sysctl -n hw.ncpu) tests;
        fi
    - ctest
    - cd ..
    - echo "------------------ MinSize Release build ------------------"
    - mkdir build.min_size
    - cd build.min_size
    - CC=${_CC} CXX=${_CXX} cmake .. ${_BUILD} ${_GLOBAL_BUILD} -DCMAKE_BUILD_TYPE=MinSizeRel
    - if [[ $TRAVIS_OS_NAME == linux ]]; then
        VERBOSE=1 sudo make -j$(nproc) tests;
        elif [[ $TRAVIS_OS_NAME == osx ]]; then
        VERBOSE=1 sudo make -j$(sysctl -n hw.ncpu) tests;
        fi
    - ctest
    - cd ..
